<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 对象格式的json数据
        var sJson1 = '{"name": "张三", "age": 20}';
        // 数组格式的json数据
        var sJson2 = '[{"gender": "男", "addr": "上海"}, {"gender": "女", "addr": "上海"}]';
        // 浏览器获取对象格式的json数据转换成JavaScript对象
        var oPerson1 = JSON.parse(sJson1);
        alert(oPerson1);
        console.log(oPerson1.name);
        // 浏览器获取数组格式的json数据转换成JavaScript对象
        var oPerson2 = JSON.parse(sJson2);
        console.log(oPerson2);
    </script>
</head>
<body>
    
</body>
</html>